Python: Autodetect version issue (26.2) [STUD-78782]#511
Python: Autodetect version issue (26.2) [STUD-78782]#511
Conversation
Search for python and python3 when detecting python Search in the install folder and in ../bin folder Remove no longer needed preprocessor directive
There was a problem hiding this comment.
Pull request overview
Updates Python runtime autodetection to be more flexible across installations and simplifies OS detection logic by removing now-unneeded preprocessor guards.
Changes:
- Extend Python autodetection to probe multiple executable names (
python/python3) and locations (<path>and<path>/bin). - Refactor autodetection to try multiple candidates and aggregate failures for easier troubleshooting.
- Remove
#if NETCOREAPPguards aroundRuntimeInformation.IsOSPlatform(...)checks.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Activities/Shared/UiPath.Shared.Service/Client/Controller.cs | Removes NETCOREAPP conditional around Windows detection. |
| Activities/Python/UiPath.Python/Service/PythonProxy.cs | Removes NETCOREAPP conditional around Windows detection. |
| Activities/Python/UiPath.Python/Impl/Engine.cs | Removes NETCOREAPP conditional around Windows detection. |
| Activities/Python/UiPath.Python/EngineProvider.cs | Implements multi-candidate Python executable probing and aggregated failure handling. |
| Activities/Python/UiPath.Python.Host.Shared/PythonService.cs | Removes NETCOREAPP conditional around Windows detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
branch name does not contain the package name |
Address review findings
|
address part of the review comments in this file
|
leave as it is for now (changing the name will require new PR) |
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Proc?.Kill(); | ||
| Proc?.Dispose(); | ||
| Proc = null; |
There was a problem hiding this comment.
Proc?.Kill() can throw (e.g., process already exited / has no associated process / access denied). If that happens, Proc?.Dispose() and Proc = null won’t run, which can reintroduce the leak this method is trying to prevent. Consider wrapping Kill() in a try/catch (or checking HasExited first), and ensure Dispose() runs in a finally-like path.
| Proc?.Kill(); | |
| Proc?.Dispose(); | |
| Proc = null; | |
| var proc = Proc; | |
| if (proc != null) | |
| { | |
| try | |
| { | |
| // Attempt to kill the process only if it has not already exited. | |
| if (!proc.HasExited) | |
| { | |
| proc.Kill(); | |
| } | |
| } | |
| catch (InvalidOperationException) | |
| { | |
| // Process may have already exited or have no associated process; ignore in dispose path. | |
| } | |
| catch (System.ComponentModel.Win32Exception) | |
| { | |
| // Access denied or other OS-level issue; ignore in dispose path to avoid masking earlier errors. | |
| } | |
| finally | |
| { | |
| proc.Dispose(); | |
| Proc = null; | |
| } | |
| } |
| private static readonly string[] PythonExeWin = ["python.exe", "python3.exe"]; | ||
| private static readonly string[] PythonLinux = ["python", "python3"]; | ||
| private static readonly string[] PythonBinFolders = ["", "bin"]; | ||
| private const string PythonVersionArgument = "--version"; |
There was a problem hiding this comment.
PR description mentions searching in the install folder and in the ../bin folder, but the current candidate generation only checks path and path/bin via PythonBinFolders = ["", "bin"]. If path can point at a .../lib location (common for some Python envs), the executable will be in a sibling ../bin and won’t be found. Consider adding an explicit ../bin candidate (e.g., include Path.Combine("..", "bin") in the folder list) and normalizing with GetFullPath after combining.



Search for python and python3 when detecting python
Search in the install folder and in ../bin folder
Remove no longer needed preprocessor directive